$(document).ready(function () {
    $('.btn-search').click(function () {
        var $innerSelect = $('#inner-select');
        var dataType = $innerSelect.attr('data-type');
        var dataId = $innerSelect.attr('data-id');

        if ( dataType == 'school' ) {
            $('tbody tr').show();
        }
        else if ( dataType == 'grade' ) {
            $('tbody tr').hide();
            $('tbody tr[data-grade="' + dataId + '"]').show();
        }
        else if ( dataType = 'class' ) {
            $('tbody tr').hide();
            $('tbody tr[data-class="' + dataId + '"]').show();
        }
    });
});

function innerSelectClicked(event) {
    var $select = $(event.currentTarget);
    var $innerSelect = $('#inner-select');

    var dataType = $select.attr('data-type');
    var dataId = $select.attr('data-id');

    $innerSelect.html($select.html());
    $innerSelect.attr('data-type', dataType);
    $innerSelect.attr('data-id', dataId);
}
